<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<title>业务介绍</title>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/style.min.css"/>
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/font-awesome.min93e3.css"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.4/themes/default/style.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/plugins/dataTables/css/jquery.dataTables.min.css"/>
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.css">
<style type="text/css">
body{font-size: 14px;padding-top: 10px;}
.btn.btn-rounded{margin-bottom: 8px;}
.ruleForm{width: 100%;border-collapse: collapse;}
.ruleForm td{border: 1px dashed #ddd;padding: 4px;}
.ruleForm select{height: 26px;width: 80px;}
.ruleForm img{cursor: pointer;}
.dataTables_info{font-size: 12px}
.dataTables_paginate{font-size: 12px;}
table.dataTable thead .sorting:after{content: ""}
table.dataTable thead .sorting_desc:after{content: ""}
</style>
</head>
<body class="gray-bg">
<div class="container-fluid">
	<div class="row">
	    <div class="col-sm-12">
	        <div class="ibox">
	       		<div style="height: 70px;margin-top: 5px;margin-bottom: -22px;">
	        		<shiro:hasPermission name="market_business_list:create">
	        		<button class="btn btn-primary" onclick="addDistinction_()" type="button" style="float: right; padding-right: 10px;">新建业务</button>
	        		</shiro:hasPermission>
	        		<!-- <button class="btn btn-primary" onclick="back_()" type="button" style="float: right; margin-right: 20px;">返回上一页</button> -->
	            </div>
	            <div class="ibox-content">
	            	<table id="myTable" class="display" align="center" style="width: 100%;">
			            <thead>
				            <tr>
				                <th width="10"></th>
				                <th>业务概览</th>
				                <th>创建时间</th>
				                <th width="70"><center>操作</center></th>
				            </tr>
			            </thead>
			        </table>
	            </div>
	        </div>
	    </div>
	</div>
</div>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.4/jstree.min.js"></script>
<script src="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/artDialog/7.0.0/dialog-plus.js"></script>
<script type="text/javascript" src="<%=path%>/js/memberGroupRule.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.16/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/marketing/jquery.cookie.js"></script>
<script type="text/javascript" src="<%=path%>/js/marketing/dialog.js"></script>
<script type="text/javascript" src="<%=path%>/js/dateUtils.js"></script>
<script type="text/javascript">
var path = "<%=path%>";
var flage;
//var groupId = getUrlParam("groupId");
/* var myDataTable;
var selectGroupDialog = null;
var access_token=$.cookie('access_token');
var cid=$.cookie('cid');
var uid=$.cookie('uid');
var send_num = 0; */

$(function(){
	$.fn.dataTable.ext.errMode = 'none';
	init();
});

function init(){	
	myDataTable = dataTable();
}

//返回上一页
function back_(){
	window.location.href="/scrm_dev/ui/mainView?menuId=132&menuName=营销管理";
}
//跳转添加业务页面
function addDistinction_(){
	location.href= path + "/distinction/toAddDistinction";
}

//删除
function del_(type){
	swal({
		  title: '您确定要删除此业务吗?',
		  text: "删除后将无法恢复，请谨慎操作！",
		  type: 'warning',
		  showCancelButton: true,
		  confirmButtonColor: '#d33',
		  cancelButtonColor: '#3085d6',
		  confirmButtonText: '删除',
		  cancelButtonText:'取消'
		}).then(function () {
			deleteOne(type);
		})
}
//删除
function deleteOne(type){
	console.log(type);
	var url=path+"/distinction/ajaxDistinctionDelete";
	$.post(url, {
		"id" : type
	}, function(data) {
		if (data == 1) {
			myDataTable.ajax.reload(1-1,false);
			successDialog("删除成功");
		}else {
			myDataTable.ajax.reload(1-1,false);
			errorDialog("已删除",data.message);
		}
	});
}

//编辑
function update_(type){
	location.href= path+"/view/ui/editDistinctio?id="+type;
}

//列表
function func_AjaxUrl() {
    return path + "/distinction/ajaxDistinctionPageList";
}

function func_columns() {
    var jsonArr = [
        {"data":"pic"},
        {"data": "title"},
        {"data": "createTime"},
        {"data": "id"}
    ];
    return jsonArr;
}

function func_ajaxData() {
    var jsonObject = new Object();
    jsonObject.groupId = groupId;
   /*  if ($.trim($("#phone").val()) != "") {
        jsonObject.phone = $("#phone").val();
    } */
    return jsonObject;
}

function dataTable() {
    return $('#myTable').DataTable({
        processing: true,
        ordering: false,
        searching: false,
        info: true,
        autoWidth: true,
        lengthChange: false,
        language: {
            emptyTable: '没有数据表',
            infoEmpty: '没有数据',
            info: '从第 _START_ 到第 _END_ 条数据；总共有 _TOTAL_ 条记录',
            lengthMenu: '每页显示 _MENU_ 条记录',
            loadingRecords: '正在加载数据....',
            processing: '正在处理数据....',
            zeroRecords: '当前页已没数据，请您点击上一页！',
            paginate: {
                first: '首页',
                previous: '前页',
                next: '后页',
                last: '尾页'
            }
        },
        order: [[1, 'desc']],
        pageLength: 10,
        pagingType: 'full_numbers',
        columnDefs: [{
            render: function (data, type, full) {         
                <%-- var result = "";
                if (data != "") {
                    result = "<img src="+data+" id='pic' style='width:79px;height:79px;'/>";
                }else{
                	result = "<img src='<%=path%>/images/marketing/img_load_error.png' id='pic' style='width:79px;height:79px;'/>";
                } --%>
                return "<img src=" + full.headPic + " id='pic' style='width:79px;height:79px;'/>";;
            },
            targets: 0
        },{
            render: function (data, type, full) {
                var result = "";
                if (data != null) {
                    result = data;
                }
                return result;
            },
            targets: 1
        },{
            render: function (data, type, full) {
                var result = "";
                if (data != null) {
                    result = formatDateTimeYMDHMS(data);
                }
                return result;
            },
            targets: 2
        },{
            render: function (data, type, full) {
                var result = "";
                if (data != null) {
//                 	var id="\'"+data+"'";
                    result = '<center>' 
                    	+ '<shiro:hasPermission name="market_business_list:update"><a onclick="update_(\'' + data + '\');">编辑</a></shiro:hasPermission>' 
                    	+ '&nbsp;&nbsp;&nbsp;' 
                    	+ '<shiro:hasPermission name="market_business_list:delete"><a onclick="del_(\'' + data + '\');">删除</a></shiro:hasPermission>' 
                    	+ '</center>';
                }
                return result;
            },
            targets: 3
        }], 
        columns: func_columns(),
        serverSide: true,
        ajax: {
            contentType: "application/json",
            type: 'POST',
            url: func_AjaxUrl(),
            data: function (d) {
                //d.extra_search = func_ajaxData();
                return JSON.stringify(d);
            }
        }
    });
}

</script>
</html>